import React, {Component} from 'react';
// 通过点击按钮更新message的内容
class HelloWorld extends Component {
    constructor() {
        super();
        this.state={
            message:'hello world'
        }
    }
    changeText(){
        this.setState({message:'你好啊'})
    }
    render() {
        const { message } = this.state
        return (
            <div>
                <h2>{message}</h2>
                <button onClick={e=>this.changeText()}>修改文本</button>
            </div>
        );
    }
    // 组件被渲染到DOM：被挂载到DOM
    componentDidMount() {
        console.log('eeeee')
    }

    // 组件从DOM中卸载掉：从DOM移除掉
    componentWillUnmount() {

    }

}
export default HelloWorld;
